#include <asm.h>
#include <regdef.h>
#include <inst_test.h>

LEAF(n1_lui_test)
    .set noreorder
    addiu s0, s0 ,1
    addiu s2, zero, 0x0
    lui   t2, 0x1
###test inst
    addiu t1, zero, 0x0
    TEST_LUI(0x0000, 0x0000)
    TEST_LUI(0x0001, 0x0000)
    TEST_LUI(0x0002, 0x0000)
    TEST_LUI(0x0003, 0x0000)
    TEST_LUI(0x0004, 0x0000)
    TEST_LUI(0x0005, 0x0000)
    TEST_LUI(0x0006, 0x0000)
    TEST_LUI(0x0007, 0x0000)
    TEST_LUI(0x0008, 0x0000)
    TEST_LUI(0x0009, 0x0000)
    TEST_LUI(0x000a, 0x0000)
    TEST_LUI(0x000b, 0x0000)
    TEST_LUI(0x000c, 0x0000)
    TEST_LUI(0x000d, 0x0000)
    TEST_LUI(0x000e, 0x0000)
    TEST_LUI(0x000f, 0x0000)
    addiu t1, zero, 0x0
    TEST_LUI(0x1010, 0x1010)
    TEST_LUI(0x1011, 0x1010)
    TEST_LUI(0x1012, 0x1010)
    TEST_LUI(0x1013, 0x1010)
    TEST_LUI(0x1014, 0x1010)
    TEST_LUI(0x1015, 0x1010)
    TEST_LUI(0x1016, 0x1010)
    TEST_LUI(0x1017, 0x1010)
    TEST_LUI(0x1018, 0x1010)
    TEST_LUI(0x1019, 0x1010)
    TEST_LUI(0x101a, 0x1010)
    TEST_LUI(0x101b, 0x1010)
    TEST_LUI(0x101c, 0x1010)
    TEST_LUI(0x101d, 0x1010)
    TEST_LUI(0x101e, 0x1010)
    TEST_LUI(0x101f, 0x1010)
    addiu t1, zero, 0x0
    TEST_LUI(0x2020, 0x2020)
    TEST_LUI(0x2021, 0x2020)
    TEST_LUI(0x2022, 0x2020)
    TEST_LUI(0x2023, 0x2020)
    TEST_LUI(0x2024, 0x2020)
    TEST_LUI(0x2025, 0x2020)
    TEST_LUI(0x2026, 0x2020)
    TEST_LUI(0x2027, 0x2020)
    TEST_LUI(0x2028, 0x2020)
    TEST_LUI(0x2029, 0x2020)
    TEST_LUI(0x202a, 0x2020)
    TEST_LUI(0x202b, 0x2020)
    TEST_LUI(0x202c, 0x2020)
    TEST_LUI(0x202d, 0x2020)
    TEST_LUI(0x202e, 0x2020)
    TEST_LUI(0x202f, 0x2020)
    addiu t1, zero, 0x0
    TEST_LUI(0x3030, 0x3030)
    TEST_LUI(0x3031, 0x3030)
    TEST_LUI(0x3032, 0x3030)
    TEST_LUI(0x3033, 0x3030)
    TEST_LUI(0x3034, 0x3030)
    TEST_LUI(0x3035, 0x3030)
    TEST_LUI(0x3036, 0x3030)
    TEST_LUI(0x3037, 0x3030)
    TEST_LUI(0x3038, 0x3030)
    TEST_LUI(0x3039, 0x3030)
    TEST_LUI(0x303a, 0x3030)
    TEST_LUI(0x303b, 0x3030)
    TEST_LUI(0x303c, 0x3030)
    TEST_LUI(0x303d, 0x3030)
    TEST_LUI(0x303e, 0x3030)
    TEST_LUI(0x303f, 0x3030)
    addiu t1, zero, 0x0
    TEST_LUI(0x4040, 0x4040)
    TEST_LUI(0x4041, 0x4040)
    TEST_LUI(0x4042, 0x4040)
    TEST_LUI(0x4043, 0x4040)
    TEST_LUI(0x4044, 0x4040)
    TEST_LUI(0x4045, 0x4040)
    TEST_LUI(0x4046, 0x4040)
    TEST_LUI(0x4047, 0x4040)
    TEST_LUI(0x4048, 0x4040)
    TEST_LUI(0x4049, 0x4040)
    TEST_LUI(0x404a, 0x4040)
    TEST_LUI(0x404b, 0x4040)
    TEST_LUI(0x404c, 0x4040)
    TEST_LUI(0x404d, 0x4040)
    TEST_LUI(0x404e, 0x4040)
    TEST_LUI(0x404f, 0x4040)
    addiu t1, zero, 0x0
    TEST_LUI(0x5040, 0x5040)
    TEST_LUI(0x5041, 0x5040)
    TEST_LUI(0x5042, 0x5040)
    TEST_LUI(0x5043, 0x5040)
    TEST_LUI(0x5044, 0x5040)
    TEST_LUI(0x5045, 0x5040)
    TEST_LUI(0x5046, 0x5040)
    TEST_LUI(0x5047, 0x5040)
    TEST_LUI(0x5048, 0x5040)
    TEST_LUI(0x5049, 0x5040)
    TEST_LUI(0x504a, 0x5040)
    TEST_LUI(0x504b, 0x5040)
    TEST_LUI(0x504c, 0x5040)
    TEST_LUI(0x504d, 0x5040)
    TEST_LUI(0x504e, 0x5040)
    TEST_LUI(0x504f, 0x5040)
    addiu t1, zero, 0x0
    TEST_LUI(0x6050, 0x6050)
    TEST_LUI(0x6051, 0x6050)
    TEST_LUI(0x6052, 0x6050)
    TEST_LUI(0x6053, 0x6050)
    TEST_LUI(0x6054, 0x6050)
    TEST_LUI(0x6055, 0x6050)
    TEST_LUI(0x6056, 0x6050)
    TEST_LUI(0x6057, 0x6050)
    TEST_LUI(0x6058, 0x6050)
    TEST_LUI(0x6059, 0x6050)
    TEST_LUI(0x605a, 0x6050)
    TEST_LUI(0x605b, 0x6050)
    TEST_LUI(0x605c, 0x6050)
    TEST_LUI(0x605d, 0x6050)
    TEST_LUI(0x605e, 0x6050)
    TEST_LUI(0x605f, 0x6050)
    addiu t1, zero, 0x0
    TEST_LUI(0x8060, 0x8060)
    TEST_LUI(0x8061, 0x8060)
    TEST_LUI(0x8062, 0x8060)
    TEST_LUI(0x8063, 0x8060)
    TEST_LUI(0x8064, 0x8060)
    TEST_LUI(0x8065, 0x8060)
    TEST_LUI(0x8066, 0x8060)
    TEST_LUI(0x8067, 0x8060)
    TEST_LUI(0x8068, 0x8060)
    TEST_LUI(0x8069, 0x8060)
    TEST_LUI(0x806a, 0x8060)
    TEST_LUI(0x806b, 0x8060)
    TEST_LUI(0x806c, 0x8060)
    TEST_LUI(0x806d, 0x8060)
    TEST_LUI(0x806e, 0x8060)
    TEST_LUI(0x806f, 0x8060)
    addiu t1, zero, 0x0
    TEST_LUI(0xa070, 0xa070)
    TEST_LUI(0xa071, 0xa070)
    TEST_LUI(0xa072, 0xa070)
    TEST_LUI(0xa073, 0xa070)
    TEST_LUI(0xa074, 0xa070)
    TEST_LUI(0xa075, 0xa070)
    TEST_LUI(0xa076, 0xa070)
    TEST_LUI(0xa077, 0xa070)
    TEST_LUI(0xa078, 0xa070)
    TEST_LUI(0xa079, 0xa070)
    TEST_LUI(0xa07a, 0xa070)
    TEST_LUI(0xa07b, 0xa070)
    TEST_LUI(0xa07c, 0xa070)
    TEST_LUI(0xa07d, 0xa070)
    TEST_LUI(0xa07e, 0xa070)
    TEST_LUI(0xa07f, 0xa070)
    addiu t1, zero, 0x0
    TEST_LUI(0xc080, 0xc080)
    TEST_LUI(0xc081, 0xc080)
    TEST_LUI(0xc082, 0xc080)
    TEST_LUI(0xc083, 0xc080)
    TEST_LUI(0xc084, 0xc080)
    TEST_LUI(0xc085, 0xc080)
    TEST_LUI(0xc086, 0xc080)
    TEST_LUI(0xc087, 0xc080)
    TEST_LUI(0xc088, 0xc080)
    TEST_LUI(0xc089, 0xc080)
    TEST_LUI(0xc08a, 0xc080)
    TEST_LUI(0xc08b, 0xc080)
    TEST_LUI(0xc08c, 0xc080)
    TEST_LUI(0xc08d, 0xc080)
    TEST_LUI(0xc08e, 0xc080)
    TEST_LUI(0xc08f, 0xc080)
    addiu t1, zero, 0x0
    TEST_LUI(0xe090, 0xe090)
    TEST_LUI(0xe091, 0xe090)
    TEST_LUI(0xe092, 0xe090)
    TEST_LUI(0xe093, 0xe090)
    TEST_LUI(0xe094, 0xe090)
    TEST_LUI(0xe095, 0xe090)
    TEST_LUI(0xe096, 0xe090)
    TEST_LUI(0xe097, 0xe090)
    TEST_LUI(0xe098, 0xe090)
    TEST_LUI(0xe099, 0xe090)
    TEST_LUI(0xe09a, 0xe090)
    TEST_LUI(0xe09b, 0xe090)
    TEST_LUI(0xe09c, 0xe090)
    TEST_LUI(0xe09d, 0xe090)
    TEST_LUI(0xe09e, 0xe090)
    TEST_LUI(0xe09f, 0xe090)
    addiu t1, zero, 0x0
    TEST_LUI(0xf0a0, 0xf0a0)
    TEST_LUI(0xf0a1, 0xf0a0)
    TEST_LUI(0xf0a2, 0xf0a0)
    TEST_LUI(0xf0a3, 0xf0a0)
    TEST_LUI(0xf0a4, 0xf0a0)
    TEST_LUI(0xf0a5, 0xf0a0)
    TEST_LUI(0xf0a6, 0xf0a0)
    TEST_LUI(0xf0a7, 0xf0a0)
    TEST_LUI(0xf0a8, 0xf0a0)
    TEST_LUI(0xf0a9, 0xf0a0)
    TEST_LUI(0xf0aa, 0xf0a0)
    TEST_LUI(0xf0ab, 0xf0a0)
    TEST_LUI(0xf0ac, 0xf0a0)
    TEST_LUI(0xf0ad, 0xf0a0)
    TEST_LUI(0xf0ae, 0xf0a0)
    TEST_LUI(0xf0af, 0xf0a0)
###detect exception
    bne s2, zero, inst_error
    nop
###score ++
    addiu s3, s3, 1
###output (s0<<24)|s3
inst_error:  
    sll t1, s0, 24
    NOP4
    or t0, t1, s3 
    NOP4
    sw t0, 0(s1)
    jr ra
    nop
END(n1_lui_test)
